From: kaf24@firebug.cl.cam.ac.uk Date: Mon, 1 May 2006 14:28:01 +0000 (+0100) Subject: Change semantics of grant transfers for vp guests so that the X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16108^2~40 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=28ba6400915b09657ef0cb6c7b0faaac0912fa68;p=xen.git Change semantics of grant transfers for vp guests so that the operation automatically gets you a fresh page at the same pseudo-physical address as Keir suggested. Signed-off-by: Isaku Yamahata --- diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c index c5ea3a8b24..a58e215163 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c @@ -235,23 +235,35 @@ static void net_rx_action(unsigned long unused) vdata = (unsigned long)skb->data; old_mfn = virt_to_mfn(vdata); - /* Memory squeeze? Back off for an arbitrary while. */ - if ((new_mfn = alloc_mfn()) == 0) { - if ( net_ratelimit() ) - WPRINTK("Memory squeeze in netback driver.\n"); - mod_timer(&net_timer, jiffies + HZ); - skb_queue_head(&rx_queue, skb); - break; - } - /* - * Set the new P2M table entry before reassigning the old data - * page. Heed the comment in pgtable-2level.h:pte_page(). :-) - */ - set_phys_to_machine(__pa(skb->data) >> PAGE_SHIFT, new_mfn); + if (!xen_feature(XENFEAT_auto_translated_physmap)) { + /* Memory squeeze? Back off for an arbitrary while. */ + if ((new_mfn = alloc_mfn()) == 0) { + if ( net_ratelimit() ) + WPRINTK("Memory squeeze in netback " + "driver.\n"); + mod_timer(&net_timer, jiffies + HZ); + skb_queue_head(&rx_queue, skb); + break; + } + /* + * Set the new P2M table entry before reassigning + * the old data page. Heed the comment in + * pgtable-2level.h:pte_page(). :-) + */ + set_phys_to_machine( + __pa(skb->data) >> PAGE_SHIFT, + new_mfn); + + MULTI_update_va_mapping(mcl, vdata, + pfn_pte_ma(new_mfn, + PAGE_KERNEL), 0); + mcl++; - MULTI_update_va_mapping(mcl, vdata, - pfn_pte_ma(new_mfn, PAGE_KERNEL), 0); - mcl++; + mmu->ptr = ((maddr_t)new_mfn << PAGE_SHIFT) | + MMU_MACHPHYS_UPDATE; + mmu->val = __pa(vdata) >> PAGE_SHIFT; + mmu++; + } gop->mfn = old_mfn; gop->domid = netif->domid; @@ -260,13 +272,6 @@ static void net_rx_action(unsigned long unused) netif->rx.req_cons++; gop++; - if (!xen_feature(XENFEAT_auto_translated_physmap)) { - mmu->ptr = ((maddr_t)new_mfn << PAGE_SHIFT) | - MMU_MACHPHYS_UPDATE; - mmu->val = __pa(vdata) >> PAGE_SHIFT; - mmu++; - } - __skb_queue_tail(&rxq, skb); /* Filled the batch queue? */ @@ -274,22 +279,24 @@ static void net_rx_action(unsigned long unused) break; } - if (mcl == rx_mcl) - return; + if (!xen_feature(XENFEAT_auto_translated_physmap)) { + if (mcl == rx_mcl) + return; - mcl[-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL; + mcl[-1].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL; - if (mmu - rx_mmu) { - mcl->op = __HYPERVISOR_mmu_update; - mcl->args[0] = (unsigned long)rx_mmu; - mcl->args[1] = mmu - rx_mmu; - mcl->args[2] = 0; - mcl->args[3] = DOMID_SELF; - mcl++; - } + if (mmu - rx_mmu) { + mcl->op = __HYPERVISOR_mmu_update; + mcl->args[0] = (unsigned long)rx_mmu; + mcl->args[1] = mmu - rx_mmu; + mcl->args[2] = 0; + mcl->args[3] = DOMID_SELF; + mcl++; + } - ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl); - BUG_ON(ret != 0); + ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl); + BUG_ON(ret != 0); + } ret = HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op, gop - grant_rx_op); @@ -308,8 +315,11 @@ static void net_rx_action(unsigned long unused) netif->stats.tx_bytes += size; netif->stats.tx_packets++; - /* The update_va_mapping() must not fail. */ - BUG_ON(mcl->result != 0); + if (!xen_feature(XENFEAT_auto_translated_physmap)) { + /* The update_va_mapping() must not fail. */ + BUG_ON(mcl->result != 0); + mcl++; + } /* Check the reassignment error code. */ status = NETIF_RSP_OKAY; @@ -340,7 +350,6 @@ static void net_rx_action(unsigned long unused) netif_put(netif); dev_kfree_skb(skb); - mcl++; gop++; }